<?php
declare (strict_types=1);

namespace Plugin\Alarm\Model;

use Mine\MineModel;
use Plugin\Device\Model\RdDeviceSerial;
use Plugin\File\Model\RdFilePlaybackVideo;

class RdAlarmMsg extends MineModel
{
    /**
     * The table associated with the model.
     *
     * @var string|null
     */
    protected ?string $table = 'rd_alarm_msg';
    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected array $fillable = [
        'id', 'type', 'alarm_pic_path', 'alarm_pic_name', 'camera_id', 'camera_url',
        'image_height', 'image_width', 'result_data', 'roi', 'src_pic_path', 
        'src_pic_name', 'task_id', 'timestamp', 'yj_data_id', 'device_serial', 
        'channel_no', 'msg_type', 'alarm_type', 'file_url', 'created_at', 'updated_at'
    ];
    /**
     * The attributes that should be cast to native types.
     *
     * @var array
     */
    protected array $casts = [
        'id' => 'integer',
        'type' => 'integer',
        'camera_id' => 'integer',
        'image_height' => 'integer',
        'image_width' => 'integer',
        'result_data' => 'array',
        'roi' => 'array',
        'task_id' => 'integer',
        'timestamp' => 'integer',
        'channel_no' => 'integer',
        'alarm_type' => 'integer',
        'created_at' => 'datetime',
        'updated_at' => 'datetime',
    ];

    public function video()
    {
        return $this->hasOne(RdFilePlaybackVideo::class, 'yj_data_id', 'yj_data_id');
    }

}